<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>

<div style="height: 20px"></div>
<div style="width: 300px">
    <form class="layui-form" action="" name="updateType" onclick="return false" id="type">
        <input type="hidden" value="{$data.id}" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">类别名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{$data.title}" placeholder="类别名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="update">立即修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>
    //添加子类
    $("#update").click(function(){
        if(!$("input[name=title]").val()){
            layer.msg('类别名称不能为空',{icon:1,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/paper_type/update')}",
            type:"post",
            data:$("#type").serialize(),
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);  // 关闭layer
                    });
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                }
            }
        });
    });
</script>
</html>